FROM redis:6.2.13-alpine3.18

MAINTAINER zhangxingjia<zhangxingjia245@163.com>

COPY ./conf/redis.conf /usr/local/etc/redis/redis.conf

EXPOSE 6379

# 关于启动容器时出现如下警告说明：
# WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
# 其中：vm.overcommit_memory = 1，表示内核允许分配所有的物理内存，而不管当前的内存状态如何
# 如果去掉警告，可在宿主机上执行：编辑/etc/sysctl.conf ，改vm.overcommit_memory=1，然后sysctl -p使配置文件生效
ENTRYPOINT ["redis-server", "/usr/local/etc/redis/redis.conf", "--appendonly", "yes"]

